<?php

class EPSDAO extends DAO
{
	public $mysqli; //see if this can still be used when private as we pass it to our delegates
	public $results = array();
	
	function __construct($host, $usr, $pwd, $db)
	{
		//comment this in if using mysql
		//$this->connect($host, $usr, $pwd, $db);
    }
	
	private function connect($host, $usr, $pwd, $db)
    {
	    /* comment this is if you want to connect to MySql
	   	$this->mysqli = new mysqli($host, $usr, $pwd);
	
		if(mysqli_connect_errno()){
			printf("Connot connect using HOST: %1$s  USR: %2$s PWD: %3$s <br> error: %4$s", $host, $usr, $pwd, $this->mysqli->error);
			die("Could not connect: " . $this->mysqli->error);
		}
	
		$db_selected = $this->mysqli->select_db($db);
		
		if (!$db_selected) {
			die ('Can\'t use ifp : ' . $this->mysqli->error);
		}
		*/
    }
	    
	public function faultTest(User $usr){
	    return ReadFault::faultTest( $usr );
	}
	
	public function updateDomain( Domain $domain ){
		return UpdateDomain::updateDomain( $domain );
	}
	
	public function updateUser( User $usr ){
		
		return UpdateUser::updateUser( $usr );
	}
	
	public function updateRole(Role $role ){
		
		return UpdateRole::updateRole( $role );
		//comment this in if using mysql
		//$this->mysqli->close();
	}
	
	public function getBoardItems( array $feddSources, $itemLimit = 3, $useCahce = true, $cacheLocation = '../cache' ){
	    return ReadBoard::getBoardItems( $feddSources, $itemLimit, $useCahce, $cacheLocation );
	}
	
	public function getUser(User $usr ){
		
		return ReadUser::getUser( $usr );
	}
	
	public function getAllUsers(){
		
		return ReadUser::getAllUsers();
	}
	
	public function getAllRoles(){
		
		$this->results = ReadRole::getAllRoles();
		return $this->results;
		//comment this in if using mysql
		//$this->mysqli->close();
	}
	
	public function listDomains(){
		return ListDomains::listDomains();
	}
    	
}

?>